package com.d0317;

import java.util.Scanner;

public class StopIOWaitThread {
    public static void main(String[] args) {
        IOWaitThread ioWaitThread=new IOWaitThread();
        System.out.println("线程启动");
        ioWaitThread.start();
      /*  try {
            Thread.sleep(100);
        }catch (InterruptedException e){
            e.printStackTrace();
        }*/
        ioWaitThread.interrupt();
        ioWaitThread.scanner.close();
    }

}
class IOWaitThread extends Thread{
    Scanner scanner = new Scanner(System.in);
    private boolean flag=true;
    @Override
    public void run() {
        while (flag){
            System.out.println("等待输入");
            scanner.nextLine();
            System.out.println("停止输入");
        }
    }
    public void stopThread(){
        flag=false;
    }
}
